package com.zimin.cloud.system.controller.api;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zimin.authorize.annotation.Authorize;
import com.zimin.cloud.mine.pojo.file.business.FaceBO;
import com.zimin.cloud.mine.pojo.system.business.AccountBO;
import com.zimin.cloud.system.pojo.entity.Account;
import com.zimin.shared.annotation.OpLog;
import com.zimin.shared.enums.ModuleEnum;
import com.zimin.shared.pojo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户信息 前端控制器 接口
 * </p>
 *
 * @author zimin
 * @since 2021-12-30 11:04
 */
@RequestMapping("/sys/account")
@Api(value = "后台用户API", tags = {"后台用户API"})
public interface IAccountController {


    /**
     * <p>查询用户列表</p>
     *
     * @param accountBO 查询参数
     * @return com.zimin.shared.pojo.Result
     * @since 2022-02-13 10:38:12
     */
    @GetMapping("/pageList")
    @Authorize(hasPerMi = "system:account:list")
    @ApiOperation(value = "查询用户列表", notes = "查询用户列表", httpMethod = "GET")
    Result accountPageList(Page<Account> accountPage, AccountBO accountBO);

    /**
     * <p>保存用户</p>
     *
     * @param accountBO
     * @return com.zimin.shared.pojo.Result
     * @since 2022-02-14 15:55:52
     */
    @PostMapping
    @Authorize(hasPerMi = "system:account:save")
    @OpLog(module = ModuleEnum.SYSTEM, action = "保存用户")
    @ApiOperation(value = "保存用户", notes = "保存用户", httpMethod = "POST")
    Result save(@RequestBody @Validated AccountBO accountBO);

    /**
     * <p>修改用户</p>
     *
     * @param accountBO 用户对象
     * @return com.zimin.shared.pojo.Result
     * @since 2022-02-14 15:59:22
     */
    @PutMapping
    @Authorize(hasPerMi = "system:account:update")
    @OpLog(module = ModuleEnum.SYSTEM, action = "修改用户")
    @ApiOperation(value = "修改用户", notes = "修改用户", httpMethod = "PUT")
    Result update(@RequestBody @Validated AccountBO accountBO);

    /**
     * 批量删除用户
     */
    @DeleteMapping
    @Authorize(hasPerMi = "system:account:delete")
    @OpLog(module = ModuleEnum.SYSTEM, action = "批量删除用户")
    @ApiOperation(value = "批量删除用户", notes = "批量删除用户", httpMethod = "DELETE")
    Result delete(@RequestParam(value = "idList") List<String> idList);

    @GetMapping("/isExist")
    @Authorize(hasPerMi = "system:account:isExist")
    @OpLog(module = ModuleEnum.SYSTEM, action = "查询admin用户是否存在")
    @ApiOperation(value = "查询admin用户是否存在", notes = "查询admin用户是否存在", httpMethod = "POST")
    Result accountIsExist(@RequestParam(name = "username") @ApiParam(name = "username") String username);

    @PutMapping("/resetPassword")
    @Authorize(hasPerMi = "system:account:reset:password")
    @OpLog(module = ModuleEnum.SYSTEM, action = "重置用户密码")
    @ApiOperation(value = "重置用户密码", notes = "重置用户密码", httpMethod = "PUT")
    Result resetPassword(@RequestBody AccountBO accountBO);

    @PutMapping("/password")
    @Authorize(hasPerMi = "system:account:reset:password")
    @OpLog(module = ModuleEnum.SYSTEM, action = "修改密码")
    @ApiOperation(value = "修改密码", notes = "修改密码", httpMethod = "PUT")
    Result updatePassword(@RequestBody @Validated AccountBO accountBO);

    @PutMapping("/faceId")
    @Authorize(hasPerMi = "system:account:face")
    @OpLog(module = ModuleEnum.SYSTEM, action = "设置人脸Id")
    @ApiOperation(value = "设置人脸Id", notes = "设置人脸图片", httpMethod = "PUT")
    Result setFaceId(@RequestBody @Validated FaceBO faceBO) throws Exception;


}
